local js_limu = fk.CreateSkill {
  name = "js__limu",
}

js_limu:addEffect("active", {
  anim_type = "control",
  card_num = 1,
  target_num = 0,
  prompt = "#js__limu",
  can_use = Util.TrueFunc,
  card_filter =function (self, player, to_select, selected)
    local card = Fk:getCardById(to_select)
    return #selected == 0 and card.suit == Card.Diamond and
      not player:isProhibited(player, Fk:cloneCard("indulgence", card.suit, card.number))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:useVirtualCard("indulgence", effect.cards, player, player, self.name, true)
    if player:isWounded() and not player.dead then
      room:recover{
        who = player,
        num = 1,
        skillName = self.name,
      }
    end
  end,
})
js_limu:addEffect("targetmod", {
  main_skill = js_limu,
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill("js__limu") and scope == Player.HistoryPhase and
    card and #player:getCardIds("j") > 0 and player:inMyAttackRange(to)
  end,
  bypass_distances = function(self, player, skill, card, to)
    return card and player:hasSkill("js__limu") and #player:getCardIds("j") > 0 and player:inMyAttackRange(to)
  end,
})

return js_limu